﻿using Microsoft.EntityFrameworkCore.ChangeTracking;


namespace SBlogCore.Common.DatabaseAccessor.Repositorys.EFCore
{
    public partial interface IRepository<TEntity> where TEntity : class, IBaseEntity
    {
        #region 插入
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        TEntity Insert(TEntity entity);
        /// <summary>
        /// 异步插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        ValueTask<TEntity> InsertAsync(TEntity entity);
        /// <summary>
        /// 异步批量插入
        /// </summary>
        /// <param name="entityParams"></param>
        /// <returns></returns>
        Task InsertRangeAsync(IEnumerable<TEntity> entityParams);
        /// <summary>
        /// 批量插入并立即保存
        /// </summary>
        /// <param name="entityParams"></param>
        /// <returns></returns>
        int InsertRangeNow(IEnumerable<TEntity> entityParams);
        /// <summary>
        /// 插入并立即保存
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int InsertNow(TEntity entity);
        /// <summary>
        /// 异步插入数据立即保存
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        ValueTask<TEntity> InsertNowAsync(TEntity entity);
        /// <summary>
        /// 异步批量插入立即保存
        /// </summary>
        /// <param name="entityParams"></param>
        /// <returns></returns>
        Task<int> InsertRangeNowAsync(IEnumerable<TEntity> entityParams);
        #endregion
    }
}